﻿using System;
using System.Configuration;
using System.Net.Http;
using System.Net.Http.Headers;

namespace In.Api.HttpClients
{
    public static class OutHttpClient
    {
        private static readonly HttpClient HttpClient;

        static OutHttpClient()
        {
            var baseAddress = ConfigurationManager.AppSettings["OutHttpClientBaseAddress"];

            var requestHandler = new WebRequestHandler();

            var client = new HttpClient(requestHandler);

            client.BaseAddress = new Uri(baseAddress);

            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            HttpClient = client;
        }
        public static HttpClient GetClient()
        {
            return HttpClient;
        }
    }
}